import { common_utils } from "../utils/utils"


export var cartService = {
  
  getCartItems: function(username,ok) {
    // TODO: implement this method
     common_utils.request({
          url: "user/" + username + "/cart",
          method: "GET",
          success: ok,
          data: null
        });
  },
  deleteCartItems: function(username,ok) {
    // TODO: implement this method
     common_utils.request({
          url: "user/" + username + "/cart",
          method: "DELETE",
          success: ok,
          data: null
        });
  },
  addCartItem: function(username,itemId,quantity,ok) {
    // TODO: implement this method
     common_utils.request({
          url: "user/" + username + "/cart/"+itemId+"?quantity="+quantity,
          method: "POST",
          success: ok,
          data: null
        });
  },
  removeCartItem: function(username,itemId,ok) {
    // TODO: implement this method
     common_utils.request({
          url: "user/" + username + "/cart/"+itemId,
          method: "DELETE",
          success: ok,
          data: null
        });
  },
  updateCartItemQuantity: function(username, itemId, quantity, ok, error) {
    common_utils.request({
      url: "user/" + username + "/cart/" + itemId + "?quantity=" + quantity,
      method: "PUT",
      success: ok,
      error: error,
      data: null
    });
  }
 


 
};